/*
 * @Title: 反向拼团-票选优品详情
 * @Author: zhj
 * @Date:   2018-12-28
 * @Last Modified by:   zhj
 * @Last Modified time: 2018-12-28
 */
var dataInfo = new Object(),
  template = {
    init: function() {
      Vue.use(VueLazyload, {
        preLoad: 1.3,
        error: 'https://h5.meetao.com/img/product/init.png',
        loading: 'https://h5.meetao.com/img/product/init.png',
        attempt: 1
      });
      dataInfo.init = new Vue({
        el: '#app',
        data: {
          barragePage: 1, //弹幕页数
          barrageLimit: 5, //弹幕一页展示多少条
          onnumLoading: false, //票选优品是否下来加载
          loading: false, //是否上拉加载
          isLoading: false, //是否下拉加载
          finished: false,
          thisNum: "", //选中当前期数
          numberList: [], //活动期数票选列表
          voteActivityMap: [], //当前活动信息
          barrageList: [], //弹幕数据
        },
        methods: {
          voteClick: function(index, event) { //跳转票选详情
            var This = event.currentTarget,
              thisText = $(This).text();
            if (thisText == "去抢购" || thisText == "已投票去抢购") {
              window.location.href = "../html/productDetails.html?isFx=1&isPx=1&voteItemCode=" + dataInfo.init.numberList[index].code + "&productId=" + dataInfo.init.numberList[index].fxVirtualGoodsCode + '&voteItemNum=' + dataInfo.init.thisNum;
            } else {
              window.location.href = "../html/FPtVoteDetails.html?voteItemCode=" + dataInfo.init.numberList[index].code + "&active=1";
            }
          },
          onNumberList: function() { //优品下拉加载
            dataInfo.init.numberList = [];
            setTimeout(function() {
              dataInfo.init.$toast('刷新成功');
              dataInfo.init.onnumLoading = false;
              dataInfo.init.getVoteForTheBestList();
            }, 500);
          },
          init: function() { //重置
            dataInfo.init.thisNum = getQueryString("activityIssueNum");
            dataInfo.init.getVoteForTheBestList();
            //						dataInfo.init.queryBarrageList(); //查询弹幕数据
          },
          onRule: function() { //跳转规则
            window.location.href = "../html/FPtRule.html";
          },
          onVoteProducts: function(num) { //跳转最新一期票选优品
            window.location.href = "../html/FPtVoteProducts.html?inviterId=" + getQueryString('inviterId');
          },
          onVoteDetails: function(index) { //跳转投票详情
            window.location.href = "../html/FPtVoteDetails.html?voteItemCode=" + dataInfo.init.numberList[index].code + '&inviterId=' + getQueryString('inviterId');
          },
          //					queryBarrageList: function() { //查询票选优品的弹幕列表
          //						ajaxTemplate(addressTest + SERVICE.queryBarrageList, function(data) {
          //							if(data.tag == 0) {
          //								setInterval(function() {
          //
          //									dataInfo.init.barrageList = dataInfo.init.barrageList.concat(data.data.result);
          //									setTimeout(function() {
          //										for(var i in dataInfo.init.barrageList) {
          //											barrageWall.upWall(dataInfo.init.barrageList[i].robotHeadImageUrl, "", dataInfo.init.barrageList[i].robotNickname);
          //										}
          //									}, 1000);
          //								},5000);
          //							} else {
          //
          //							}
          //						}, {
          //							page: dataInfo.init.barragePage++,
          //							limit: "3"
          //						});
          //					},
          getVoteForTheBestList: function() { //获取票选优品的列表
            console.log(dataInfo.init.thisNum);
            ajaxTemplate(addressTest + SERVICE.getVoteForTheBestList, function(data) {
              if (data.tag == 0) {
                console.log(data);
                dataInfo.init.voteActivityMap = data.data.result.voteActivityMap;
                dataInfo.init.numberList = data.data.result.list;
              } else {

              }
            }, {
              userId: userId,
              voteActivityIssueNum: dataInfo.init.thisNum
            });
          },
        },
      });
      dataInfo.init.init();
    }
  };
template.init();
